using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using EnvironmentFile.Targets;
using System.IO;

namespace EnvironmentFile.Tests
{
	[TestClass]
	public class ReplaceTokensTest
	{
		[TestMethod]
		[DeploymentItem("../../../EnvironmentFile.Tests/Data/test.config")]
		[DeploymentItem("../../../EnvironmentFile.Tests/Data/test.env")]
		public void ShouldReplaceTokenInConfigFile()
		{
			ReplaceTokensTask task = new ReplaceTokensTask();
			task.ConfigFile = "test.config";
			task.TokenPattern = "--([^-]+)--";
			task.EnvironmentFile = "test.env";
			Assert.IsTrue(task.Execute(), "execution of the task failed");
			Assert.IsTrue(File.ReadAllText(task.ConfigFile).Contains("this is a replaced string"));
		}
	}
}
